package com.chushouya.controller.order.clerk;

import com.chushouya.common.annotations.AuthValidate;
import com.chushouya.common.constant.ServiceType;
import com.chushouya.common.support.Contexts;
import com.general.framework.core.schema.Response;
import com.chushouya.order.dto.api.clerk.ClerkOrderDataDTO;
import com.chushouya.order.dto.api.clerk.ClerkOrderDataQuery;
import com.chushouya.order.dto.api.clerk.ClerkOrderDayStatDTO;
import com.chushouya.order.service.api.ClerkDashboardApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Api(tags = ServiceType.CLERK + "业务员数据看板")
@RestController
@RequestMapping(ServiceType.CLERK + "/dashboard")
public class ClerkDashboardApiController {

    @Resource
    private ClerkDashboardApiService clerkDashboardApiService;

    @GetMapping("/orderTotalData")
    @ApiOperation("业务员订单数据汇总")
    @AuthValidate
    public Response<ClerkOrderDataDTO> orderTotalData(ClerkOrderDataQuery query) {
        query.setClerkId(Contexts.getUserContext().getClerkId());
        return Response.success(clerkDashboardApiService.orderTotalData(query));
    }

    @GetMapping("/orderDayData")
    @ApiOperation("业务员订单每日数据")
    @AuthValidate
    public Response<List<ClerkOrderDayStatDTO>> orderDayData(ClerkOrderDataQuery query) {
        query.setClerkId(Contexts.getUserContext().getClerkId());
        return Response.success(clerkDashboardApiService.orderDayData(query));
    }

}
